package com.ruoyi.gybj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gybj.domain.MessageRecord;
import com.ruoyi.gybj.service.IMessageRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息推送记录Controller
 * 
 * @author ruoyi
 * @date 2025-11-19
 */
@RestController
@RequestMapping("/message/record")
public class MessageRecordController extends BaseController
{
    @Autowired
    private IMessageRecordService messageRecordService;

    /**
     * 查询消息推送记录列表
     */
    @PreAuthorize("@ss.hasPermi('message:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(MessageRecord messageRecord)
    {
        startPage();
        List<MessageRecord> list = messageRecordService.selectMessageRecordList(messageRecord);
        return getDataTable(list);
    }

    /**
     * 导出消息推送记录列表
     */
    @PreAuthorize("@ss.hasPermi('message:record:export')")
    @Log(title = "消息推送记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MessageRecord messageRecord)
    {
        List<MessageRecord> list = messageRecordService.selectMessageRecordList(messageRecord);
        ExcelUtil<MessageRecord> util = new ExcelUtil<MessageRecord>(MessageRecord.class);
        util.exportExcel(response, list, "消息推送记录数据");
    }

    /**
     * 获取消息推送记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('message:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(messageRecordService.selectMessageRecordById(id));
    }

    /**
     * 新增消息推送记录
     */
    @PreAuthorize("@ss.hasPermi('message:record:add')")
    @Log(title = "消息推送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MessageRecord messageRecord)
    {
        return toAjax(messageRecordService.insertMessageRecord(messageRecord));
    }

    /**
     * 修改消息推送记录
     */
    @PreAuthorize("@ss.hasPermi('message:record:edit')")
    @Log(title = "消息推送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MessageRecord messageRecord)
    {
        return toAjax(messageRecordService.updateMessageRecord(messageRecord));
    }

    /**
     * 删除消息推送记录
     */
    @PreAuthorize("@ss.hasPermi('message:record:remove')")
    @Log(title = "消息推送记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(messageRecordService.deleteMessageRecordByIds(ids));
    }
}
